import "reflect-metadata";
import { Injectable } from "@nestjs/common";

export interface ICar {
  run(): void;
}

export class Car implements ICar {
  run() {
    console.log("汽车在跑...");
  }
}

@Injectable()
export class Driver {
  drive(car: ICar) {
    car.run();
  }
}

function Inject(target: object, key: string) {
  console.log("target ————》", target);
  console.log("key ————》", key);
  target[key] = new (Reflect.getMetadata("design:type", target, key))();
}

class A {
  sayHello() {
    console.log("hello");
  }
}

class B {
  @Inject
  a!: A;

  say() {
    this.a.sayHello();
  }
}

new B().say();
